<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@page import="com.limetalks.data.User"%>
<%@page import="com.limetalks.util.Helper"%>
<%@page import="com.limetalks.data.Category"%>
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<% session.setAttribute("TEST1", "VALUE1"); %>
<html>
<head>
	<title>New Stream</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link rel="stylesheet" type="text/css" href="css/LT.css">
	<script type="text/javascript" src="js/LT.js" ></script>
	
	<link rel="stylesheet" type="text/css" href="css/jModal.css" />
	<script src="js/jquery-1.6.4.js" language="javascript" type="text/javascript"></script>
	
	<!-- ajax file uploader -->
	<link rel="stylesheet" type="text/css" href="js/fileuploader.css">
	<script type="text/javascript" src="js/fileuploader.js" ></script>
	
</head>
<body>
	<div id="modalWin" style="position:absolute;"></div>
	<center>
		<jsp:include page="header.jsp"> 
			<jsp:param name="user" value="" />
		</jsp:include>
		
		
		<div style="font-family: tahoma,arial,verdana,sans-serif,Lucida Sans; font-size: 11px; border:1px solid #CCCCCC;  width:800px; height:655px;">
	
		
			<div style="border-bottom:1px solid #cccccc; padding:10px; text-align:center; background:#F6F6F6; background:#8EB934; color:white;">
				<b>New Stream</b> 
			</div>
		
		<%  Object user = request.getSession().getAttribute("user");
			if(user != null) { 
				Integer userId = ((User)user).getId();		
		%>
		
			<div style="padding-top:20px; text-align:left;  padding-left:200px;">
				Title: <input type="text" name="name" id="streamName" style="margin-left:80px;"/><br>
				Category: <select id="streamCategory" style="margin-left:55px;">
  					<% for (Category c : Helper.getAllCategories()) { %>
  					<option value="<%=c.getId()%>"><%=c.getName()%></option>
				  	<% } %>
				</select><br>
				<span id='uploadSpan'>
					<input type="button" value="Upload File">
				</span><br>
				Width: <input type="text" name="vwidth" id="vwidth" style="margin-left:80px;"/><br>
				Height: <input type="text" name="vheight" id="vheight" style="margin-left:80px;"/><br>
				Fps: <input type="text" name="vfps" id="vfps" style="margin-left:80px;"/><br>
				Quality: <input type="text" name="vquality" id="vquality" style="margin-left:80px;"/><br>
				<!--  Image: <input type="file" name="file1"><br>-->
				<input type="hidden" id="imageName" name="image">
				<input type="button" onclick="createStream();" value="Create new Stream" style="margin-top:15px; margin-left:80px; padding-left:10px; padding-right:10px;">
				
			</div>
		</div>
		
		
		<jsp:include page="footer.jsp" /> 	
		
	</center>
	
	<% String fileName = "u" + userId + "_" + Helper.randomString() + ".jpg"; %>
	
	<script type="text/javascript">
		var lol = new qq.FileUploaderBasic({
	        button: document.getElementById('uploadSpan'),
	        action: 'OctetStreamReader',
	        allowedExtensions: ['jpg', 'png', 'jpeg', 'gif', 'pdf'],
	        params: {
	            filename: '<%=fileName%>'
	        },
	        onComplete: function(id, fileName, responseJSON) {
	        				alert("Done id: "+id+", fileName: "+fileName+", responseJSON: "+responseJSON);   	
	        				document.getElementById('imageName').value = '<%=fileName%>';
	        			}
      });
	</script>
	
	<% } else { %>
	
		You need to sign in to create streams.
	
	<% }  %>

</body>
</html>